package nl.mayisal.metadata.columns;

import java.sql.ResultSet;
import java.sql.SQLException;

public abstract class AbstractColumnStructure<T> {
	private final String name;
	private boolean nullable;
	private final int type;
	private final int length;
	private final String defaultValue;
	
	public AbstractColumnStructure(int type, String name, int length, String defaultValueExpression) {
		this.type = type;
		this.name = name;
		this.length = length;
		this.defaultValue = defaultValueExpression;
	}
	public String getName() {
		return this.name;
	}
	public boolean getNullable() {
		return this.nullable;
	}
	public void setNullable(boolean nullable) {
		this.nullable = nullable;
	}
	public int getType() {
		return this.type;
	}
	public int getLength() {
		return this.length;
	}
	public String getDefaultValue() {
		return this.defaultValue;
	}
	
	@SuppressWarnings("unchecked")
	public T getValue(ResultSet resultSet) throws SQLException {
		return (T)resultSet.getObject(this.name);
	}
}
